package org.speed.jdk;

import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.Date;


public class GenIdWorker {

	static void gen18Id() throws UnknownHostException {
		//6位时间
		StringBuffer sbf = new StringBuffer();
		SimpleDateFormat dateFormat = new SimpleDateFormat("YYMMdd");
		sbf.append(dateFormat.format(new Date()));
		
		//2位机房号
		sbf.append("18");
		
		System.out.println(sbf.toString());
		
		InetAddress addr = InetAddress.getLocalHost();
		
		String hostAddr = addr.getHostAddress();
		System.out.println(hostAddr);	

		hostAddr = hostAddr.substring(hostAddr.length()-2).replace(".", "0");
		System.out.println(hostAddr);	
		
	}
	
	public static void main(String[] args) throws Exception {
		gen18Id();
		
		
	}

}
